//
//  PortraitView.m
//  AppleMarket
//
//  Created by yangy on 15/11/2018.
//  Copyright © 2018 szgsy. All rights reserved.
//

#import "PortraitView.h"

@interface PortraitView()
@property (nonatomic, strong) UILabel *nickLabel; // 呢称
@property (nonatomic, strong) UILabel *uidLabel;    // uid
@property (nonatomic, strong) UIImageView *iconView; // 头像
@end

@implementation PortraitView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if(self){
        [self addSubview:self.iconView];
        [self addSubview:self.nickLabel];
        [self addSubview:self.uidLabel];
        [self setViewLayout];
    }
    return self;
}

- (void) setImage:(UIImage*) image nickName:(NSString*) nickStr uidStr:(NSString*) uidSTr
{
    self.iconView.image = image;
    self.nickLabel.text = nickStr;
    self.uidLabel.text = uidSTr;
}

- (void) setViewLayout
{
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.mas_left).offset(15);
        make.centerY.mas_equalTo(self.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(33, 33));
    }];
    
    [_nickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.iconView.mas_right).offset(7);
        make.bottom.mas_equalTo(self.iconView.mas_centerY).offset(-1.5);
    }];
    
    [_uidLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.nickLabel);
        make.top.mas_equalTo(self.iconView.mas_centerY).offset(1.5);
    }];
}

- (UIImageView *)iconView
{
    if(!_iconView){
        _iconView = [[UIImageView alloc] init];
    }
    return _iconView;
}

- (UILabel *)nickLabel
{
    if(!_nickLabel){
        _nickLabel = [UILabel cm_labelWithText:@"" font:kFont(13) textColor:kColorWithHex(0x4A647A)];
    }
    return _nickLabel;
}

- (UILabel *)uidLabel
{
    if(!_uidLabel){
        _uidLabel = [UILabel cm_labelWithText:@"" font:kFont(10) textColor:kColorWithHex(0xADB7C1)];
    }
    return _uidLabel;
}


@end
